let vm = new Vue({
    el: '#app',  //选中整个main
    data() {
        return {
            page: {},
            focus: {
                userId: '',
                userFocusId: ''
            },
        }
    },
    methods: {
        selectPage: function (start = 1, pageSize = 5) {
            let parse = JSON.parse(sessionStorage.getItem("user"));
            this.focus.userId = parse.id;
            axios({
                url: `user/selectFocusUsers/${start}/${pageSize}`,
                params: {
                    userId: parse.id
                }
            }).then(response => {
                //不成功提示
                if (response.data.success) {
                    //把登陆成功的用户存到session去
                    this.page = response.data.obj;
                    /*for (let i = 0; i <this.page.list.length ; i++) {
                        this.page.list[i].flag=false;
                    }*/
                    for (let i = 0; i < this.page.list.length; i++) {
                        // this.resources[i].arrow=false;
                        Vue.set(this.page.list[i], 'flag', false)
                    }
                } else {
                    //登陆失败
                    layer.msg(response.data.msg);
                    //刷新验证码
                    this.refresh();
                }
            }).catch(error => {
                layer.msg(error.message);
            })
        },
        todetil: function (user) {
            layer.obj = user;
            if (user.isSecret==1){
                layer.msg("对方已设置权限，您无权访问");
            }else {
                layer.open({
                    type: 2,
                    title: '更新',
                    maxmin: false,
                    closeBtn:1,
                    shadeClose: true, //点击遮罩关闭层
                    area: ['1000px', '80%'],
                    content: 'html/user_detail.html',
                });
            }
        },
        setFocus: function (focusId) {
            this.focus.userFocusId = focusId;
            //取消关注
            axios.put("user/cancekFocus", this.focus).then(result => {
                layer.msg(result.data.msg);
                this.selectPage();
            }).catch(error => {
                layer.msg(error.message)
            })
        }
    },
    created: function () {
        this.selectPage();
        console.log(this.page)
    }
});